Expand description

Reactive primitives for Sycamore.

Structs

A reference to a reactive scope. This reference is Copy, allowing it to be copied into closures without any clones.

A mutable reference for modifying a Signal.

A signal that is not bound to a Scope.

A read-only Signal.

A handle that allows cleaning up a Scope.

A container of reactive state that can be updated and subscribed to.

A struct for managing subscriptions to signals.

Traits

A trait that is implemented for all ReadSignals regardless of the type parameter.

Functions

Create a child scope.

Creates an effect on signals used inside the effect closure.

Creates an effect on signals used inside the effect closure.

Creates a memoized computation from some signals. The output is derived from all the signals that are used within the memo closure. If any of the tracked signals are updated, the memo is also updated.

Create a new RcSignal with the specified initial value.

Create a new RcSignal with the specified initial value wrapped in a Rc.

An alternative to create_signal that uses a reducer to get the next value.

Allocate a new arbitrary value under the current Scope. The allocated value lasts as long as the scope and cannot be used outside of the scope.

Creates a reactive scope.

Creates a reactive scope, runs the callback, and disposes the scope immediately.

Creates a memoized value from some signals. Unlike create_memo, this function will not notify dependents of a change if the output is the same. That is why the output of the function must implement PartialEq.

Creates a memoized value from some signals. Unlike create_memo, this function will not notify dependents of a change if the output is the same.

Create a new Signal under the current Scope. The created signal lasts as long as the scope and cannot be used outside of the scope.

Create a new Signal under the current Scope but with an initial value wrapped in a Rc. This is useful to avoid having to clone a value that is already wrapped in a Rc when creating a new signal. Otherwise, this is identical to create_signal.

Function that maps a Vec to another Vec via a map function. The mapped Vec is lazy computed, meaning that it’s value will only be updated when requested. Modifications to the input Vec are diffed by index to prevent recomputing values that have not changed.

Function that maps a Vec to another Vec via a map function. The mapped Vec is lazy computed, meaning that it’s value will only be updated when requested. Modifications to the input Vec are diffed using keys to prevent recomputing values that have not changed.

A helper function for making it explicit to define dependencies for an effect.

Adds a callback that is called when the scope is destroyed.

Provides a context in the current Scope. The context can later be accessed by using use_context lower in the scope hierarchy.

Provides a context in the current Scope. The context can later be accessed by using use_context lower in the scope hierarchy.

Returns the current depth of the scope. If the scope is the root scope, returns 0.

Tries to get a context value of the given type. If no context with the right type found, returns None. For a panicking version, see use_context.

Run the passed closure inside an untracked dependency scope.

Gets a context value of the given type.

Gets a context value of the given type or computes it from a closure.

Gets a context value of the given type or computes it from a closure.

Returns a RcSignal that is true when the scope is still valid and false once it is disposed.

Type Definitions

A type-alias for BoundedScope where both lifetimes are the same.